package problem506;

import java.util.Arrays;

//506.相对名次
//https://leetcode.cn/problems/relative-ranks/description/?envType=problem-list-v2&envId=heap-priority-queue&difficulty=EASY

class Solution {
    public String[] findRelativeRanks(int[] score) {
        int n = score.length;
        String[] ret = new String[n];
        int[][] arr = new int[n][2];
        for(int i = 0; i<n; i++) {
            arr[i][0] = score[i];
            arr[i][1] = i;
        }
        Arrays.sort(arr, (a, b)->b[0] - a[0]);
        for(int i = 0; i<n; i++) {
            if(i == 0) {
                ret[arr[i][1]] = "Gold Medal";
            }else if(i == 1) {
                ret[arr[i][1]] = "Silver Medal";
            }else if(i == 2) {
                ret[arr[i][1]] = "Bronze Medal";
            }else {
                ret[arr[i][1]] = "" + (i+1);
            }
        }
        return ret;
    }
}

/*

10 1
3  2
8  3
9  4
4  5

*/